import java.util.*;

public class PerceptronDataSet {
    private int dimension;
    private ArrayList<double[]> dataSet;
    private ArrayList<Integer> labelSet;

    public PerceptronDataSet(int dimension) throws Exception {
        setDimension(dimension);
        dataSet = new ArrayList<>();
        labelSet = new ArrayList<>();
    }

    public void addData(double[] vec, int label) throws Exception {
        if (vec.length != dimension)
            throw new DimensionException(
                "the dimension of vector must be " +
                "the same as PerceptronDataSet");
        dataSet.add(vec);
        if ((label != -1) && (label != 1))
            throw new Exception("Label must be -1 or 1");
        labelSet.add(label);
    }

    public int getDimension() {
        return this.dimension;
    }
    
    public ArrayList<double[]> getDataSet() {
        return this.dataSet;
    }

    public ArrayList<Integer> getLabelSet() {
        return this.labelSet;
    }

    private void setDimension(int dimension) throws Exception {
        if (dimension <= 0)
            throw new DimensionException(
                "Dimension must be a positive integer.");
        this.dimension = dimension;
    }
}
